package base

import (
	"errors"
	"hft/Database/admin"
	"hft/Http/Models/dao"
	"hft/e"
	"hft/tools"

	"gorm.io/gorm"
)

// 公共的操作

// 查找账号
func FindAccount(claims tools.BaseClaims, tx *gorm.DB) (a *admin.Account, err error) {

	var account *admin.Account
	err = tx.Scopes(dao.ParseAccountDao.Parse(claims, tx)).First(&account).Error
	if err != nil {
		return nil, errors.New(e.AccountNotExist)
	}
	return account, nil
}
